import { BaseMode,ZipCodeValidator,numberRegexp,Calculator,test } from "./interface";
import { Utils } from "./util";

import * as Interface3 from "./3_interface";

//Node.js里的动态模块加载
declare function require(moduleName: string): any;
//require.js里的动态模块加载
declare function require(moduleNames: string[], onLoad: (...args: any[]) => void): void;
//System.js里的动态模块加载
declare const System: any;

//interface file in interface & 3_interface
let util = new Utils();
export class ModuleTest implements BaseMode{
    run(){

    let myValidator = new ZipCodeValidator();
    util.log(myValidator.isAcceptable("05911"),"ZipCodeValidator");
    util.log(numberRegexp.test("2165496"),"numberRegexp-2165496");

    if (true){
        //NodeJS
        let Validator: typeof Interface3 = require("./3_interface");
        let validator = new Validator.RegExpBasedZipCodeValidator();
        if (validator.isAcceptable("05912")) { 
            util.log("isAcceptable 05912","require module");
            /* ... */
        }
        // require(["./3_interface"], (Validator: typeof Interface3) => {
        //     let validator = new Validator.RegExpBasedZipCodeValidator();
        //     if (validator.isAcceptable("05912")) { 
        //         util.log("isAcceptable 05912","require module");
        //         /* ... */
        //     }
        // });
    }
    let myValidator2 = new Interface3.RegExpBasedZipCodeValidator();
    util.log(myValidator.isAcceptable("0592"),"RegExpBasedZipCodeValidator");
    
   
    let c = new Calculator();
    test(c, "1+2*33/11="); // prints 9

    c = new Interface3.Calculator(2);
    test(c, "001+010="); // prints 3

    c = new Interface3.Calculator(10);
    test(c, "1+2*33/11="); // prints 3
    }
}